package tools

import (
	"github.com/sirupsen/logrus"
	"os"
)

var Log = logrus.New()

func init() {
	Log.Formatter = &logrus.JSONFormatter{}
	f, err := os.OpenFile("logs/error.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)

	if err != nil {
		return
	}

	// 将自定义日志输出至 logs/error.log 文件中
	Log.Out = f
	// 设置日志级别
	Log.Level = logrus.InfoLevel
}